package tech.iboot.consumer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import tech.iboot.consumer.service.IEchoService;

/**
 * @author luohong
 * @date 2021/4/7
 */
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
@RestController
public class TestController {
    @Autowired
    private RestTemplate restTemplate;
    @Autowired
    private IEchoService iEchoService;
    @GetMapping("/sleep")
    public String sleep() {
        return restTemplate.getForObject("http://service-provider/sleep", String.class);
    }
    @GetMapping("/test")
    public String test() {
        return restTemplate.getForObject("http://service-provider/test", String.class);
    }
    @GetMapping("/echo-feign/{str}")
    public String feign(@PathVariable String str) {
        return iEchoService.echo(str);
    }
    @GetMapping("/divide-feign")
    public String divide(@RequestParam Integer a, @RequestParam Integer b) {
        return iEchoService.divide(a, b);
    }
    @GetMapping("/divide-feign2")
    public String divide(@RequestParam Integer a) {
        return iEchoService.divide(a);
    }
    @GetMapping("/notFound")
    public String notFound() {
        return iEchoService.notFound();
    }
}
